;
function getOption() {
    var id = $('#id').val();
    var opType = $('#opType').val();
    if (opType == 0) {
        $("#htmlTitle").html("新建关键字");
    } else if (opType == 1) {
        $("#htmlTitle").html("编辑关键字");
    }
    if (opType == 2) {
        $("#back").click(function () {
            $.ajaxSetup({cache: false});
            $(".mainDiv").load('htmlWeb/systemKeywordHtml', '', function () {
                $.getScript("../../by-webhtml/assets/js/system/system_keyword.js");
            });
        });
    } else {
        $(".save").click(function () {
            var options = {
                dataType: 'json',
                success: function (data) {
                    if (data.msg == 'success') {
                        /*if (data.r != null) alert("关键字编辑成功");
                        else alert("关键字新建成功");*/
                        $.ajaxSetup({cache: false});
                        $(".mainDiv").load('htmlWeb/systemKeywordHtml', '', function () {
                            $.getScript("../../by-webhtml/assets/js/system/system_keyword.js");
                        });
                    } else {
                        if (data.r != null) alert("关键字编辑失败");
                        else alert("关键字新建失败");
                    }
                }
            };
            $("#keywordForm").ajaxForm(options);
        });
        $("#cancel").click(function () {
            $.ajaxSetup({cache: false});
            $(".mainDiv").load('htmlWeb/systemKeywordHtml', '', function () {
                $.getScript("../../by-webhtml/assets/js/system/system_keyword.js");
            });
        });
    }
    $.post("htmlWeb/keyword/getOption", {id: id}, function (data) {
        var _keyParent = "";
        $.each(data.parentId, function (index, obj) {
            _keyParent += '<option value="' + obj.id + '">' + obj.name + '</option>'
        });
        $("#parentId").append(_keyParent);
        if (id != ''&& id != undefined) {
            $("#keywordForm").setValues(data.keyword);
        }
    });
}
$(function () {
    getOption();
});